package procedure;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 * 工序ID
 *
 * @author sk.z
 */
public class WorkId {

    private Set<String> set = new HashSet<>();

    public WorkId(){}

    public WorkId(String id){
        this.set.add(id);
    }

    public void merge(WorkId org) {
        if (Objects.isNull(org)){
            return;
        }
        this.set.addAll(org.getSet());
    }

    public Set<String> getSet() {
        return set;
    }

    public boolean isNotEmpty(){
        return !this.set.isEmpty();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        WorkId tar = (WorkId) o;
        if (this.set.size() == tar.set.size()) {
            for (String s : this.set) {
                if (!tar.set.contains(s)) {
                    return false;
                }
            }
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return Objects.hash(set);
    }

    @Override
    public String toString() {
        return "WorkId{" + set + '}';
    }
}
